package com.sky.controller;

import com.alibaba.fastjson.JSON;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @projectName: netty-cloud
 * @package: com.sky.controller
 * @className: ApiController
 * @author: zhl
 * @description: TODO
 * @date: 2024/4/28 15:31
 * @version: 1.0
 */
@RestController
public class ApiController {

    @GetMapping("/getSession")
    public String getSession(){
        SecurityContext securityContext = SecurityContextHolder.getContext();
        Authentication authentication = securityContext.getAuthentication();
        Object credentials = authentication.getCredentials();
        return JSON.toJSONString(credentials);
    }
}
